home *** CD-ROM | disk | FTP | other *** search
- " object to control updating of AA window "
- "
- *
- * window.self,v 1.18 1993/07/22 00:15:23 richards Exp
- *
- * window.self,v
- * Revision 1.18 1993/07/22 00:15:23 richards
- * Moved back to having event handlers per operation.
- * eventHandler/buttons now support substitution.
- * poly.self has primitive substitution handler, except that it has
- * no concept of context.
- *
- * Revision 1.17 1993/07/18 20:22:37 richards
- * Added substitution of polynomials (not quite working properly yet).
- * Some tests for this added to test4.
- * Buttons work, selections work, and eventHandling is coming along.
- *
- * Revision 1.16 1993/07/14 21:42:10 richards
- * Moved event handling out of the equationView and into a seperate set of object.
- * Equation selecting works!
- *
- * Revision 1.15 1993/07/13 21:47:06 richards
- * July 13 checkin.
- *
- * Revision 1.14 1993/06/24 21:24:35 richards
- * Split drawing out of boites and into light weight views.
- *
- * Revision 1.13 1993/06/23 21:18:13 richards
- * Daily checkin.
- *
- * Revision 1.12 1993/06/23 02:04:26 richards
- * Progress towards being able to select equations.
- *
- * Revision 1.11 1993/06/23 00:36:10 richards
- * Fixed up test1 to work with new code.
- * boites and window have first hack at highlighting code.
- *
- * Revision 1.10 1993/06/21 21:39:26 richards
- * Added highlighting.
- * Moved gc cache into viewManager.
- *
- * Revision 1.9 1993/06/18 21:25:44 richards
- * Moved font support into viewManager.
- * Starting to add selection stuff into window and boite.
- * Boites refer properly back to the polynomial structures.
- *
- * Revision 1.8 1993/06/03 21:33:18 richards
- * Fixed up the redrawing of the subviews. Turned out they were being drawn off the screen
- * due to faulty thinking about where the areas really were.
- *
- * Revision 1.7 1993/06/02 21:17:10 richards
- * I am slowly dealing with window redrawing and resizing requests and getting deeper
- * into navel and X. The problem is either too many configureNotify requests, or not enough
- * of them. Also, there seems to be some kind of problem filing window.self in twice.
- *
- * Revision 1.6 1993/05/31 20:27:59 richards
- * symbols has the whole greek alphabet, but some letters are not named right.
- * window.self noww uses two sub-classes of compoundView, one inside the other.
- * (Still have problem identifying them...)
- * test7 obsolete.
- * Fixed some problems with font positioning in boites and poly.
- *
- * Revision 1.5 1993/05/31 15:00:12 richards
- * Changed the view to be two views: topView and an equationView. topView is divided up nicely.
- *
- * Revision 1.4 1993/05/31 00:12:20 richards
- * May 30 checkin. Font support is nearly debugged.
- * Make use of glue now.
- * Added rational (fraction) types.
- *
- * Revision 1.3 1993/05/30 21:41:14 richards
- * Adding font support to boites.
- *
- * Revision 1.2 1993/05/23 23:16:47 richards
- * Uses the newer X primitives rather than the Self based X code.
- *
- # Revision 1.1 1993/04/28 22:30:46 richards
- # Initial revision
- #
- *
- *
- "
-
- aa _AddSlotsIfAbsent: (| views* = (). |)
- aa views _AddSlotsIfAbsent: (| traits = () |)
- aa views _AddSlotsIfAbsent: (| prototypes* = () |)
-
- aa views traits _AddSlotsIfAbsent: ( |
- topView = ().
- equationView = ().
- masterEquationView = ().
- stackEquationView = ().
- buttonView = ().
- |)
-
- aa views prototypes _AddSlotsIfAbsent: (|
- topView = ().
- equationView = ().
- masterEquationView = ().
- stackEquationView = ().
- buttonView = ().
- |)
-
-
-
- aa views traits topView _Define: (|
- _ parent** = traits compoundView.
- ^ printString = ('AA equation: ', title).
-
- "Window System Parameters"
-
- parameters* = (|
- _ leftMargin = 5.
- _ topMargin = 5.
- _ rightMargin = 5.
- _ bottomMargin= 5.
- |).
-
- copying* = (|
- copyUnrealised: sv = (| c. |
- c: resend.copyUnrealised: sv.
- c stackViews: vector copySize: 6 FillingWith: nil.
- c buttons: vector copySize: (aa views editorButtons allButtons size + 1) FillingWith: nil.
- c drawLock: drawLock copy.
- c subViewDo: [|:s|
- s fixUpSuperViewSlots.
- ].
- c
- ).
- |).
-
- "title"
- ^ title = ( iTitle ).
- ^ title: aString = (
- iTitle: aString.
- self
- ).
-
- recalculateSubViewSizes = (
- subViewDo: [|:s| s recalculateSubViewSize. ].
- captionTextPos: 10@((area height) - 20).
- ).
-
- events* = (|
- ^ configureNotify: event = (
- redrawBusy.
- resend.configureNotify: event.
- recalculateSubViewSizes.
- ('top configureNotify area: ',event area printString) printLine.
- redrawUnbusy.
- ).
- ^ expose: event = (
- redraw.
- ).
- |).
-
- drawing* = (|
- clear = (window clear).
- drawAt: p String: s = (
- window drawString: s At: p GC: manager gc
- ).
- drawAt: p String: s InFont: fontStruct = (
- manager gc font: fontStruct fid.
- window drawString: s At: p GC: manager gc.
- ).
- |).
-
- ^ simpleRedraw = (
- 'simple redraw' printLine.
- drawAt: captionTextPos String: captionText.
- subViewDo: [|:s| s redraw ].
- ).
-
- ^ redrawBusy = (
- 'redrawBusy' printLine.
- drawLock protect: [
- drawBusy: true.
- ].
- ).
-
- ^ redrawUnbusy = (
- 'redrawUnbusy' printLine.
- drawLock protect: [
- drawBusy: false.
- ].
- needRedraw ifTrue: [ redraw ].
- ).
-
- ^ redrawProtect: aBlock = (| doRedraw. |
- doRedraw: false.
- drawLock protect: [
- drawBusy ifTrue: [
- needRedraw: true. " flag that we need a redraw "
- ] False: [
- drawBusy: true. " flag that we are busy "
- doRedraw: true.
- ].
- ].
- doRedraw ifTrue: [
- aBlock value.
- drawLock protect: [
- drawBusy: false.
- needRedraw: false.
- ].
- ].
- ).
-
- redraw = (
- redrawProtect: [ simpleRedraw ].
- ).
-
- ^ masterEquation = (
- masterEquationView isNil ifFalse: [ masterEquationView equation].
- ).
- ^ masterEquation: eqn = (
- masterEquationView isNil ifFalse: [ masterEquationView equation: eqn. ].
- ).
- ^ stackEquationAt: pos = (
- (stackViews at: pos) equation
- ).
- ^ stackEquationAt: pos Put: eqn = (
- (stackViews at: pos) equation: eqn
- ).
-
- ^ topViewInitialise = (| sv. buttonOrigin. temp. |
- removeSubViews.
- sv: aa masterEquationView copy.
- sv removeSubViews.
- addSubView: sv.
- 0 to: 5 Do: [|:sp|
- sv: aa stackEquationView copy.
- sv removeSubViews.
- sv stackPos: sp.
- addSubView: sv.
- ].
- temp: (area height / 6).
- buttonOrigin: 10@((temp*5) + (temp/3)).
- aa views editorButtons allButtons do: [|:aButton. nb. |
- nb: aButton copy.
- nb translateTo: (buttonOrigin + ((40 * aButton buttonNum)@0)).
- addSubView: nb.
- ].
- ).
-
- activeWindowStackSize = 10.
- lastActiveWindow: win = (
- (activeWindowStack size > activeWindowStackSize) ifTrue: [
- activeWindowStack removeLast.
- ].
- activeWindowStack addFirst: win.
- ).
-
- caption: text = (
- clearRectangle: (captionTextPos)#((area width)@20).
- captionText: text.
- drawAt: captionTextPos String: captionText.
- ).
-
- userError: text = (
- text printLine. "XXX - put window and do graphical error"
- ).
-
- equation: eqn = (
- " XXX - should push the previous one onto the derivation list, and the undo stack "
- ('Setting master equation to: ' , eqn printString) printLine.
- masterEquation: eqn.
- ).
- |)
-
-
- aa views prototypes topView _Define: compoundView
- aa views prototypes topView _AddSlots: (|
- _ parent* = aa views traits topView.
- "_" iArea <- (0@0)##(800@@400).
- "_" iIcon <- 'AlgebraAssistant'.
- "_" masterEquationView.
- "_" stackViews.
- "_" buttons.
- "_" iTitle <- 'Unnamed'.
- ^ titleFontName <- '-*-Courier-*-r-*-*-18-*-*-*-*-*-*-*'.
- "_" titleFont.
- _ drawLock <- semaphore copyBinary.
- _ drawBusy <- false.
- _ needRedraw <- false.
- ^ activeWindowStack <- list copy. " XXX - should be a stack "
- ^ handlerForNextWindow <- aa editor selectionEventHandler.
- ^ captionText <- 'no help'.
- ^ captionTextPos <- 0@0.
- "_" iEventMask <- xlib events keyPressMask
- || xlib events exposureMask
- || xlib events structureNotifyMask
- || xlib events buttonReleaseMask.
- debugFlag <- false.
- |)
-
-
- aa views traits equationView _Define: (|
- _ parent** = traits compoundView.
- ^ printString = ('AA equation: ', eqnname).
-
- "Window System Parameters"
-
- parameters* = (|
- _ leftMargin = 5.
- _ topMargin = 5.
- _ rightMargin = 5.
- _ bottomMargin = 5.
- |).
-
- copying* = (|
- copyUnrealised: sv = (| c. |
- c: resend.copyUnrealised: sv.
- c boiteSubViews: boiteSubViews copyRemoveAll.
- c viewHandler: viewHandler copyForView: c.
- c
- ).
- |).
-
- realisation* = (|
- realise: v = (
- resend.realise: v.
- self).
-
- basicUnrealise = (
- resend.basicUnrealise.
- self
- ).
-
- |).
-
- ^ calculateSubViewSize = (
- error: 'subclass responsability'.
- ).
-
- ^ recalculateSubViewSize = (
- calculateSubViewSize.
- area: area.
- recalculatePosition.
- ).
-
- events* = (|
-
- ^ expose: event = (
- redraw.
- manager flush.
- ).
-
- |).
-
- _ viewEvents* = (|
- ^ enterNotify: event = (
- (viewHandler handlerName = topView handlerForNextWindow handlerName) ifFalse: [
- viewHandler: topView handlerForNextWindow copyForView: self.
- 'handling ' print. self print. ' with ' print. viewHandler printLine.
- ].
- viewHandler enter: (event x)@(event y).
- ).
- ^ selectDown: pt = ( topView lastActiveWindow: self. viewHandler selectDown: pt ).
- ^ selectUp: pt = ( topView lastActiveWindow: self. viewHandler selectUp: pt ).
- ^ copyDown: pt = ( topView lastActiveWindow: self. viewHandler copyDown: pt ).
- ^ copyUp: pt = ( topView lastActiveWindow: self. viewHandler copyUp: pt ).
- ^ motionNotify: event = ( topView lastActiveWindow: self. viewHandler motion: (event x@event y) ).
- |).
-
- ^ recalculatePosition = (| centerX. centerY. |
- centerX: (area width)/2.
- centerY: (area height)/2.
- equationBoites isNil ifFalse: [
- equationOrigin: (centerX - (equationBoites xSize / 2))@centerY.
- equationBBox: ((equationOrigin x)@(centerY - equationBoites posy))##(equationBoites extent).
- ].
- ).
-
-
- ^ simpleRedraw = (
- clear.
- drawInFixedFontAt: 3@10 String: eqnname.
-
- subViewDo: [| :aSv |
- aSv simpleRedraw.
- ].
- ).
-
- ^ redrawProtect: drawBlock = ( superView redrawProtect: drawBlock ).
-
- ^ redraw = (
- superView redrawProtect: [ simpleRedraw ].
- ).
-
- ^ equation = ( iEquation ).
- ^ equation: eqn = (
- iEquation: eqn.
- redrawProtect: [
- equationBoites: eqn makeBoite.
- equationBoites fixUpFonts: self.
- equationBoites makeRequiredSizes.
- recalculatePosition.
- removeSubViews.
- boiteSubViews removeAll.
- equationBoites createLWViewOn: self At: equationOrigin.
- ].
- redraw.
- ).
- |)
-
- aa views prototypes equationView _Define: compoundView
- aa views prototypes equationView _AddSlots: (|
- _ parent* = aa views traits equationView.
- "_" eqnname <- 'unnamed'.
- "_" iEquation.
- "_" equationBoites.
- "_" equationBBox <- (0@0)##(0@@0).
- "_" equationOrigin <- 0@0.
- ^ viewHandler <- aa editor selectionEventHandler copy.
- "_" boiteSubViews <- dictionary copy.
- "_" areaSelect.
- "_" iEventMask <- xlib events keyPressMask
- || xlib events exposureMask
- || xlib events buttonPressMask
- || xlib events buttonReleaseMask
- || xlib events enterWindowMask.
- debugFlag <- false.
- |)
-
- aa views traits masterEquationView _Define: (|
- _ parent* = aa views traits equationView.
- ^ calculateSubViewSize = ( | xSize. ySize. |
- xSize: superView area width.
- ySize: superView area height.
- iArea: (leftMargin@topMargin)##((2*((xSize/3)-leftMargin))@@(((5*ySize)/6)-(2*topMargin))).
- ).
-
- ^ fixUpSuperViewSlots = (
- superView masterEquationView: self.
- )
- |)
-
- aa views prototypes masterEquationView _Define: aa views prototypes equationView
- aa views prototypes masterEquationView _AddSlots: (|
- ^ parent* = aa views traits masterEquationView.
- "_" eqnname <- 'master: unnamed'.
- |)
-
- aa views traits stackEquationView _Define: (|
- _ parent** = aa views traits equationView.
- ^ calculateSubViewSize = ( | xSize. ySize. width3. height6. |
- xSize: superView area width.
- ySize: superView area height.
- width3: xSize / 3.
- height6: ySize / 6.
- iArea: (((2*width3)+leftMargin)@((stackPos*height6)+topMargin))#
- ((xSize - rightMargin)@(((stackPos+1)*height6)-bottomMargin)).
- ).
- ^ fixUpSuperViewSlots = (
- superView stackViews at: stackPos Put: self.
- ).
- |)
-
- aa views prototypes stackEquationView _Define: aa views prototypes equationView
- aa views prototypes stackEquationView _AddSlots: (|
- ^ parent* = aa views traits stackEquationView.
- "_" eqnname <- 'stack: unnamed'.
- stackPos <- 1.
- |)
-
-
-
-